

import 'dart:math';

import 'package:uuid/uuid.dart';
import 'package:xim/common/util/system.dart';

class RoundUtility {

  static String roundString(int length) {
    final random = Random();
    const availableChars = 'AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz1234567890';
    final randomString = List.generate(length,
            (index) => availableChars[random.nextInt(availableChars.length)])
        .join();
    return randomString;
  }

  /// uuid
  static String uuid() {
    return const Uuid().v4().replaceAll("-", "");
  }

  /// 随机文件名称
  static String roundFileName(String suffix, {int len=8, String? prefix}) {
    return "${(prefix??'')+roundString(len).sub(end: len)}.$suffix";
  }

}